package com.android.zhhr.ui.activity;

import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.android.zhhr.R;
import com.android.zhhr.data.commons.LoginManager;
import com.android.zhhr.data.entity.User;
import com.android.zhhr.ui.activity.base.BaseFragmentActivity;
import com.android.zhhr.utils.ZToast;

import butterknife.BindView;
import butterknife.OnClick;

public class LoginActivity extends BaseFragmentActivity {
    @BindView(R.id.et_phone_number)
    EditText et_phone;
    @BindView(R.id.et_input_code)
    EditText et_password;
    @BindView(R.id.tv_login)
    TextView tv_login;

    @Override
    protected void initView() {

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_login;
    }




    @OnClick(R.id.tv_login)
    public void login(){
        if (!TextUtils.isEmpty(et_phone.getText()) && !TextUtils.isEmpty(et_phone.getText())){
            User login = LoginManager.getInstance(getBaseContext())
                    .login(et_phone.getText().toString(), et_password.getText().toString());
            if (login!=null){
                ZToast.makeText(this, String.format("用户%s登录成功", login.getUserName()),1000).show();
                finish();
            }else {
                ZToast.makeText(this, "账号或密码错误",1000).show();
            }
        }
    }


}
